package com.example.administrator.yanfoxconn.adapter;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.yanfoxconn.R;
import com.example.administrator.yanfoxconn.activity.KKCHeckListActivity;
import com.example.administrator.yanfoxconn.activity.KLCheckActivity;
import com.example.administrator.yanfoxconn.bean.KKGWMessage;
import com.example.administrator.yanfoxconn.bean.KLMessage;

import java.util.List;


/**
 * 安保部-聯絡單查詢列表 的 適配器
 * Created by song on 2021/11/3.
 */

public class KLCheckListAdapter extends BaseAdapter {

    private KLCheckActivity activity;
    private List<KLMessage> lists;


    public KLCheckListAdapter(KLCheckActivity activity, List<KLMessage> lists) {

        this.activity = activity;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        Log.e("--------","lists.size()==="+lists.size());
        return lists.size();
    }

    @Override
    public Object getItem(int i) {
        return lists.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        int num = position +1;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_kl_check_list, null);

            holder.tvName = convertView.findViewById(R.id.tv_documentName);
            holder.tvType = convertView.findViewById(R.id.tv_type);
            holder.tvMan = convertView.findViewById(R.id.tv_excuteman);
            holder.tvScope = convertView.findViewById(R.id.tv_scope);
            holder.tvDepart = convertView.findViewById(R.id.tv_depart);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvName.setText(lists.get(position).getDocumentName());
        holder.tvType.setText(lists.get(position).getType());
        holder.tvMan.setText(lists.get(position).getExcuteman());
        holder.tvScope.setText(lists.get(position).getScope());
        holder.tvDepart.setText(lists.get(position).getDepart());


        return convertView;
    }

    private class ViewHolder {
        public TextView tvName, tvType, tvMan, tvScope,tvDepart;//檔案名稱,類型，承辦人，試用範圍，申請單位
    }
}
